home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / LProgressIndicator & Friends / LProgressDialog / LSingleLineCaption.cp < prev    next >
Encoding:
Text File  |  1996-04-21  |  3.0 KB  |  118 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LSingleLineCaption.cp                   ©1993-1995 Metrowerks Inc. All rights reserved.
  3. //                                            ©1996 Chris K. Thomas.
  4. // ===========================================================================
  5. //
  6. //    LCaption optimized for a single line of text.
  7. //
  8.  
  9. #ifdef PowerPlant_PCH
  10. #include PowerPlant_PCH
  11. #endif
  12.  
  13. #include "LSingleLineCaption.h"
  14. #include <LStream.h>
  15. #include <UDrawingUtils.h>
  16. #include <UDrawingState.h>
  17. #include <UTextTraits.h>
  18.  
  19. #ifndef __TEXTUTILS__
  20. #include <TextUtils.h>
  21. #endif
  22.  
  23.  
  24. // ---------------------------------------------------------------------------
  25. //        • CreateCaptionStream
  26. // ---------------------------------------------------------------------------
  27. //    Create a new Caption object from the data in a Stream
  28.  
  29. LSingleLineCaption*
  30. LSingleLineCaption::CreateCaptionStream(
  31.     LStream    *inStream)
  32. {
  33.     return (new LSingleLineCaption(inStream));
  34. }
  35.  
  36.  
  37. // ---------------------------------------------------------------------------
  38. //        • LSingleLineCaption
  39. // ---------------------------------------------------------------------------
  40. //    Default Constructor
  41.  
  42. LSingleLineCaption::LSingleLineCaption()
  43. {
  44. }
  45.  
  46.  
  47. // ---------------------------------------------------------------------------
  48. //        • LSingleLineCaption(const LSingleLineCaption&)
  49. // ---------------------------------------------------------------------------
  50. //    Copy Constructor
  51.  
  52. LSingleLineCaption::LSingleLineCaption(
  53.     const LSingleLineCaption    &inOriginal)
  54.         : LCaption(inOriginal)
  55. {
  56. }
  57.  
  58.  
  59. // ---------------------------------------------------------------------------
  60. //        • LSingleLineCaption(LStream*)
  61. // ---------------------------------------------------------------------------
  62. //    Construct from data in a Stream
  63.  
  64. LSingleLineCaption::LSingleLineCaption(
  65.     LStream    *inStream)
  66.         : LCaption(inStream)
  67. {
  68. }
  69.  
  70.  
  71. // ---------------------------------------------------------------------------
  72. //        • ~LSingleLineCaption
  73. // ---------------------------------------------------------------------------
  74. //    Destructor
  75.  
  76. LSingleLineCaption::~LSingleLineCaption()
  77. {
  78. }
  79.  
  80.  
  81. // ---------------------------------------------------------------------------
  82. //        • DrawSelf
  83. // ---------------------------------------------------------------------------
  84. //    Draw the Caption -- optimized for a single line with clear ’til
  85. //                      end-of-line behavior - without flashing
  86.  
  87. void
  88. LSingleLineCaption::DrawSelf()
  89. {
  90.     Rect    frame;
  91.     CalcLocalFrameRect(frame);
  92.     
  93.     StClipRgnState    clipto(frame);
  94.     
  95.     Int16    just = UTextTraits::SetPortTextTraits(mTxtrID);
  96.     
  97.     RGBColor    textColor;
  98.     ::GetForeColor(&textColor);
  99.     
  100.     ApplyForeAndBackColors();
  101.     ::RGBForeColor(&textColor);
  102.  
  103.     MoveTo(frame.left, frame.bottom - 3); // ••• fixme -- Use FontInfo
  104.     DrawString(mText);
  105.     
  106.     //
  107.     // QuickDraw has now set the pen horizontal coord
  108.     // to the end of the drawn text
  109.     //
  110.     PenState    ourPen;
  111.     GetPenState(&ourPen);
  112.     
  113.     frame.left = ourPen.pnLoc.h;
  114.     EraseRect(&frame);
  115.     
  116. //    UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0], frame, just);
  117. }
  118.